//
//  NetworkMonitor.h
//  InstantUang
//
//  Created by Bin on 2024/12/12.
//

#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
#import <CoreTelephony/CTCarrier.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, NetworkStatus) {
    NetworkStatusUnknown          = -1,
    NetworkStatusNotReachable     = 0,
    NetworkStatusWWAN2G          = 1,
    NetworkStatusWWAN3G          = 2,
    NetworkStatusWWAN4G          = 3,
    NetworkStatusWWAN5G          = 4,
    NetworkStatusWiFi            = 5
};

typedef void(^NetworkStatusBlock)(NetworkStatus status);

@interface NetworkMonitor : NSObject

/// 当前网络状态
@property (nonatomic, assign, readonly) NetworkStatus currentStatus;
/// 当前网络状态描述
@property (nonatomic, copy, readonly) NSString *currentStatusString;

@property (nonatomic, strong) NetworkStatusBlock networkStatusBlock;

+ (instancetype)sharedMonitor;

/// 开始监听网络状态
- (void)startMonitoringWithBlock:(NetworkStatusBlock)block;

/// 停止监听网络状态
- (void)stopMonitoring;

@end

NS_ASSUME_NONNULL_END
